// Tags: Build
#include <cstdio>
#include <cstring>

const int N = 5e2 + 5;
int n, m, cnt;
char map[N][N], ans[N][N][2];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("B.in", "r", stdin);
  freopen("B.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) { scanf("%s", map[i] + 1); }
  memset(ans, '0', sizeof(ans));
  for (int i = 1; i <= n; ++i) ans[i][1][0] = '1', ans[i][m][1] = '1';
  for (int i = 1; i <= n; ++i) {
    if (i & 1) {
      for (int j = 2; j < m; ++j) {
        ans[i][j][0] = '1';
        if (map[i - 1][j] == '1') { ans[i - 1][j][0] = '1'; }
        if (map[i + 1][j] == '1') { ans[i + 1][j][0] = '1'; }
      }
    } else {
      for (int j = 2; j < m; ++j) {
        ans[i][j][1] = '1';
        if (map[i - 1][j] == '1') { ans[i - 1][j][1] = '1'; }
        if (map[i + 1][j] == '1') { ans[i + 1][j][1] = '1'; }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) putchar(ans[i][j][0]);
    putchar('\n');
  }
  putchar('\n');
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) putchar(ans[i][j][1]);
    putchar('\n');
  }
  return 0;
}